﻿using System.Web;

namespace JustinAngel.MetroBlog.Models
{
    public class SidebarModel
    {
        public SidebarModel(string permLink, string title)
        {
            PermLink = permLink;
            Title = title;
        }

        public string PermLink { get; set; }

        public string Title { get; set; }

        private const string ByTwitter = "@JustinAngel";

        private const string LinkPrefix = @"http://JustinAngel.net/";

        public string TwitterLink
        {
            get
            {
                return string.Format("https://twitter.com/intent/tweet?text={0}+by+{1}+@+&url={2}{3}",
                        HttpUtility.UrlEncode(Title),
                        HttpUtility.UrlEncode(ByTwitter),
                        HttpUtility.UrlEncode(LinkPrefix),
                        HttpUtility.UrlEncode(PermLink));
            }
        }

        public string FacebookLink
        {
            get
            {
                return string.Format("http://www.facebook.com/sharer.php?u={2}{3}&t={0}+by+{1}",
                    HttpUtility.UrlEncode(Title),
                    HttpUtility.UrlEncode(ByTwitter),
                    HttpUtility.UrlEncode(LinkPrefix),
                    HttpUtility.UrlEncode(PermLink));
            }
        }

        public string RedditLink
        {
            get
            {
                return string.Format("http://www.reddit.com/submit?url={2}{3}&title={0}+by+{1}",
                                    HttpUtility.UrlEncode(Title),
                                    HttpUtility.UrlEncode(ByTwitter),
                                    HttpUtility.UrlEncode(LinkPrefix),
                                    HttpUtility.UrlEncode(PermLink));
            }
        }
    }
}
